Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(testing): add raw_path to ASGI scope #2331

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

aarcex3
Copy link
Contributor

@aarcex3 aarcex3 commented Sep 17, 2024

Summary of Changes

Added a 'raw_path' key to the asgi scope in create_scope to preserve the path and keep consistency as per #2159

Related Issues

Closes #2262

Pull Request Checklist

  • Added tests for changed code.
  • Coding style is consistent with the rest of the framework.

@aarcex3
Copy link
Contributor Author

aarcex3 commented Sep 17, 2024

I have an issue with mypy, dunno if it's only me. It complains about line 680 in testing/helpers.py.

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f1a7f2d) to head (df59212).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2331   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        64           
  Lines         7726      7727    +1     
  Branches      1071      1071           
=========================================
+ Hits          7726      7727    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this initiative @aarcex3!

However, it seems there is a misunderstanding regarding the actual implementation.
In ASGI, raw path is presented as the raw_path key inside scope. The value is a bytestring path, excluding any query string.

Furthermore, I think this improvement warrants a newsfragment, let's add one.

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that some other gates are failing too, not just Mypy.

falcon/testing/helpers.py Outdated Show resolved Hide resolved
@vytas7 vytas7 changed the title refactor (testing): preserve raw path in scope creation feat(testing): add raw_path to ASGI scope Oct 6, 2024
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement, it seems to function as intended now!

I have a couple of nitpicks wrt testing (commented inline); and we also need a news fragment for this issue. The file should be named docs/_newsfragments/2262.newandimproved.rst.

Unfortunately, we have no bandwidth to help shaping up this PR for the impending beta release that we are trying to haste in order to catch up with CPython 3.13, so we'll have to postpone this PR to Falcon 4.1. No specific action is required from you wrt this point, this is just for reference, that we will not be able to merge this PR until 4.0.0 stable is out.

tests/asgi/test_testing_asgi.py Outdated Show resolved Hide resolved
tests/asgi/test_testing_asgi.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve TestClient to automatically add raw_path to ASGI scope
2 participants